Package-level declarations

Types

Link copied to clipboard
@ApiStatus.Experimental
class ChoiceQuestionSpec : Question<ClassificationResult>

A question that asks the model to pick one option from a closed set.

Link copied to clipboard
@ApiStatus.Experimental
sealed interface DecisionAnswer

The answer to one question in a decision response. There is one implementation per question kind and no other implementation can exist, so a Kotlin when or a Java switch over an answer covers every case.

Link copied to clipboard
@ApiStatus.Experimental
class DecisionCapabilities

What a decision service can accept, as the service reports it: the question kinds it answers. Create one with of.

Link copied to clipboard
@ApiStatus.Experimental
class DecisionProjection<T : Any>

A caller-owned value read out of a decision response, kept together with the response it came from. Build one with one of the of overloads, which read the response's answered values and convert them to the target type with Jackson. The default mapper fails when a constructor parameter of the target has no answered value, so a record component with no matching question is an error. A mapper passed in keeps its own settings.

Link copied to clipboard
@ApiStatus.Experimental
class DecisionProjectionException constructor(message: String, questions: List<String>, cause: Throwable? = null) : RuntimeException

Thrown when a decision response's answers cannot be projected to a caller's target type: either one or more answers carry no representable value, or the values that were collected do not fit the target type.

Link copied to clipboard
@ApiStatus.Experimental
open class DecisionRequest

One decision spec together with the input it should be evaluated against.

Link copied to clipboard
@ApiStatus.Experimental
class DecisionResponse

The answers a model gave to a decision spec, one per question, in spec order.

Link copied to clipboard

Classification plus proposition assessment. Applications own any routing or revision policy.

Link copied to clipboard
@ApiStatus.Experimental
interface DecisionServiceMetadata : ClassificationServiceMetadata

Pure metadata for the decision family, which also supports classification.

Link copied to clipboard
@ApiStatus.Experimental
open class DecisionSpec

An immutable, ordered set of questions to put to a model in one decision. Question names are unique within a spec and name the answers in a response.

Link copied to clipboard
@ApiStatus.Experimental
annotation class DecisionSpecDsl

Marks the receiver types of the Kotlin decision spec DSL. Inside a block with a marked receiver, calls cannot reach an outer marked receiver without an explicit label, so a question block cannot add a question to the enclosing spec by accident.

Link copied to clipboard
@ApiStatus.Experimental
class DecisionSpecScope

The receiver passed to a decisionSpec block. Each method here adds one question to the spec being built, through the matching DecisionSpec.Builder method, so a spec built with this DSL validates exactly like one built with the builder or with Questions.named(...).

Link copied to clipboard
@ApiStatus.Experimental
data class LevelProbability constructor(val levelId: String, val probability: Double)

The probability a provider reported for one level of a rating scale. The id is nonblank and the probability is finite and between 0 and 1 inclusive.

Link copied to clipboard
@ApiStatus.Experimental
class PropositionQuestionSpec : Question<PropositionResult>

A question that asks the model whether a proposition is true.

Link copied to clipboard
@ApiStatus.Experimental
class PropositionRequest(val input: String, val proposition: String)

Text and a nonblank proposition to assess against it. Input may be empty. The default string representation omits both text fields.

Link copied to clipboard
@ApiStatus.Experimental
sealed interface PropositionResult

A proposition assessment keeps false answers, insufficient evidence, and failures distinct.

Link copied to clipboard
@ApiStatus.Experimental
sealed interface Question<out R : Any>

An immutable question definition whose answers have type R. The three implementations are PropositionQuestionSpec, ChoiceQuestionSpec and RatingQuestionSpec, and no other implementation can exist.

Link copied to clipboard
@ApiStatus.Experimental
enum QuestionKind : Enum<QuestionKind>

The closed set of question kinds. Each kind fixes the result type of its questions.

Link copied to clipboard
@ApiStatus.Experimental
object Questions

The starting point for declaring a question on its own. A question declared this way can be kept in a field, added to several specs, and used to look up its typed answer in a response.

Link copied to clipboard
@ApiStatus.Experimental
data class RatingLevel constructor(val id: String, val description: String = id)

One level on an ordinal rating scale, such as one point on a five-point mood scale. The id identifies the level on the wire and in provider responses. The description defaults to the id, so a caller can name a level once and use that name as both its identity and its label.

Link copied to clipboard
@ApiStatus.Experimental
class RatingQuestionSpec : Question<RatingResult>

A question that asks the model to rate something on an ordered scale of levels. The first level has index 0 and the last has index levels.size - 1.

Link copied to clipboard
@ApiStatus.Experimental
sealed interface RatingResult

The evidence a provider returned for a rating question: a selected level, a per-level distribution, a score, or any combination of these. Each part comes from the provider's response as reported. A selected level is present only when the provider selected one, and a distribution only when the provider reported one. Validation against a RatingQuestionSpec checks that a selected level and a distribution belong to the question's scale.

Link copied to clipboard
@ApiStatus.Experimental
data class RatingScore constructor(val value: Double, val statistic: RatingStatistic)

A single numeric score reported for a rating, together with the statistic it represents. The value is finite and at least zero.

Link copied to clipboard
@ApiStatus.Experimental
enum RatingStatistic : Enum<RatingStatistic>

The statistic that a RatingScore reports.

Link copied to clipboard
@ApiStatus.Experimental
class UnsupportedDecisionException(message: String) : UnsupportedOperationException

Thrown when a decision service cannot answer a request because a question kind is missing from its capabilities.

Functions

Link copied to clipboard
@ApiStatus.Experimental
fun decisionSpec(block: DecisionSpecScope.() -> Unit): DecisionSpec

Builds a decision spec with a Kotlin receiver DSL. The block declares questions on DecisionSpecScope and runs once. The spec is built once, after the block returns, so later calls on a leaked question builder cannot change it.